//Added by Dinghao Li
#pragma once

#include <iostream>
// #include <fstream>
// #include <sstream>
#include <algorithm>
// #include <memory>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <deque>
#include <bitset>
// #include <windows.h>
// #include "stdio.h"

#include "stdneb.h"
#include "timing/timer.h"
#include "math/scalar.h"
#include "math/vector.h"
#include "util/string.h"
#include "util/set.h"
#include "util/dictionary.h"
#include "util/hashtable.h"
#include "util/deque.h"
#include "util/bitfield.h"


#include "core/logManager.h"


using namespace std;
using namespace Math;
using namespace Util;

using namespace Core;

#define START_PERFORMANCE(i) \
	LARGE_INTEGER BeginTime##i; \
	LARGE_INTEGER Frequency##i; \
	QueryPerformanceFrequency(&Frequency##i); \
	QueryPerformanceCounter(&BeginTime##i);

#define END_PERFORMANCE(i) \
	LARGE_INTEGER EndTime##i; \
	QueryPerformanceCounter(&EndTime##i); \
	std::cout <<"Performance(Millisecond) : "<< ( EndTime##i.QuadPart - BeginTime##i.QuadPart )*1000 / Frequency##i.QuadPart ;




static unsigned __int64 BeginTime_PF = 0;

static unsigned __int64 EndTime_PF = 0;

__forceinline void PERFORMANCE_BEGIN()
{
	__asm
	{
		rdtsc
			mov	dword ptr [ BeginTime_PF ], eax
			mov	dword ptr [ BeginTime_PF + 4 ], edx
	}
};

__forceinline void PERFORMANCE_END(const char* args)
{
	__asm
	{
		rdtsc
			mov	dword ptr [ EndTime_PF ], eax
			mov	dword ptr [ EndTime_PF + 4 ], edx
	}

	std::cout <<"Performance(CPU cycles) : "<< EndTime_PF - BeginTime_PF << " ----- "  << args << std::endl;
};
